<?php

declare(strict_types=1);

namespace app\index\logic;

use app\common\model\Config as ModelConfig;
use app\common\logic\Config as LogicConfig;

class Config extends LogicConfig
{
    // +----------------------------------------------------------------------
    // | 获取系统配置
    // +----------------------------------------------------------------------

    /**
     * 根据配置键获取对应的键值
     *
     * @param string $key 配置键
     */
    public static function getValueBykey(string $key)
    {
        $data = ModelConfig::field('key,value,note')->where('key', $key)->findOrEmpty();
        $data->isEmpty() && fault('系统配置丢失');
        return [$data->value, $data->note];
    }
}
